package com.sdy.dcsb.web.controller.inboundservice.util;

import lombok.extern.slf4j.Slf4j;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * <p>
 *  DCSBID生成工具
 * </p>
 *
 * @author fb
 * @since 2019/11/5
 */
@Slf4j
public class DcsbIdUtil {

    /**
     * 生产36位的DCSBID。
     *
     * @param serverName
     * @return
     */
    public static String getEsbId(String serverName) {
        String dcsbId = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        int random = new Random().nextInt(1000000);
        if((serverName == null) || (serverName.length() < 1)) {
            serverName = "DCSB_";
        }
        dcsbId = serverName + sdf.format(new Date()) + "_" + random + "00000000000000000000000000";
        return dcsbId.substring(0, 36);
    }

}
